package com.ruoyi.outpatient.utils;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class DateOutpatientUtils {

    /*判断时间是否为上午下午*/
    /*0为上午,1为下午*/
    public static int ifDate(long time){
        GregorianCalendar ca = new GregorianCalendar();
        Date date = new Date();
        date.setTime(time);
        ca.setTime(date);
        return ca.get(GregorianCalendar.AM_PM);
    }


    /**
     * 获取当前日期是星期几<br>
     *
     * @param date
     * @return 当前日期是星期几
     */
    public static String getWeekOfDate(Date date) {
        String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0)
            w = 0;
        return weekDays[w];
    }

    public static void main(String args[]){
        System.out.println(getWeekOfDate(new Date()));
    }
}
